Ext.apply(Ext.form.VTypes, {
  		Year2K:  function(v) {
      		return /^20[0-9][0-9]$/.test(v);
  		},
    Year2KText: '请输入以20开头的年份信息',
    Year2KMask: /[0-9]/i
});

PaymentsWindow = function(title){
	//定义一个load方法给让表单加载数据信息
	var loadInfo = function(rec){
		form.getForm().loadRecord(rec);
		
	}
	//获取表单信息并定义事件
	var submit = function(){
		var data = form.getForm().getValues();
		this.fireEvent('submit',this,form,data);
	}
	
	//建立form表单
	var form = new Ext.form.FormPanel(
		{
			frame:true,
			autoHeight: true,
			defaults:{anchor:'80%'},
			items:[
				{xtype:'hidden',name:'userid'},
				{
					xtype:'textfield',
					name:'name',
					readOnly:true,
					fieldLabel:'用户名称'
				},
				{
					xtype:'numberfield',
					name:'shouldpay',
					fieldLabel:'应收金额'
				},
				{
					xtype:'numberfield',
					name:'realpay',
					fieldLabel:'实收金额'
				},
				{
					xtype:'numberfield',
					name:'discount',
					fieldLabel:'优惠金额'
				},
				{
					xtype:'numberfield',
					name:'minuspay',
					fieldLabel:'减免金额'
				},
				{
					xtype:'textfield',
					name:'receiptno',
					fieldLabel:'票号'
				},
				{
					xtype:'datefield',
					value:new Date(),
					
					format:'Y-m-d',
					name:'paydate',
					fieldLabel:'日期'
				},
				{
					xtype:'textfield',
					name:'telephone',
					fieldLabel:'联系电话'
				},
				{
					xtype:'textfield',
					name:'payyear',
					vtype:'Year2K',
					allowBlank:false,
					fieldLabel:'缴费年度'
				},
				{
					xtype:'textfield',
					name:'oweyear',
					fieldLabel:'欠费年度'
				},
				{
					xtype:'textarea',
					name:'notes',
					fieldLabel:'备注'
				},{
					xtype:'hidden',
					name:'fid'
				}]
		}
	);
	
	//这里是Window的配置项
	var config = {
		load:loadInfo,
		buttons:[
			{
				text:'确定',
				iconCls:'confirm',
				handler:submit,
				scope:this
			},
			{
				text:'取消',
				iconCls:'cancel',
				handler:function(){this.close()},
				scope:this
			}],
		items:[form],
		layout:'fit',
		constrain : true, 
		constrainHeader : true, 
		modal:true,
		iconCls:'money_yen',
		title:title,
		width:400,
		autoHeight:true 
	};
	PaymentsWindow.superclass.constructor.call(this,config);
}
Ext.extend(PaymentsWindow,Ext.Window);